package com.example.sofa_model;

import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewbinding.ViewBinding;
import androidx.viewpager.widget.ViewPager;

import com.blankj.utilcode.util.LogUtils;
import com.example.common.mvvm.view.BaseFragment;
import com.example.sofa_model.databinding.FragmentSofaBinding;
import com.flyco.tablayout.SlidingTabLayout;

import java.util.ArrayList;
import java.util.Map;

public class SofaFragment extends BaseFragment<FragmentSofaBinding,SofaViewModel> {


    private SlidingTabLayout sofaSlidingLayout;
    private ViewPager sofaVp;

    @Override
    public View bindLayout() {
        return v.getRoot();
    }

    @Override
    public ViewBinding initBind() {
        return FragmentSofaBinding.inflate(inflater);
    }

    @Override
    public void initView() {
        sofaSlidingLayout = v.sofaSlidingLayout;
        sofaVp = v.sofaVp;

    }

    @Override
    public void initData() {
        ArrayList<Fragment> fragments = new ArrayList<>();

        SofaTabFragment imageFragment = new SofaTabFragment();
        { Bundle bundle = new Bundle();
            bundle.putString("target", "image");
            imageFragment.setArguments(bundle);
        }

        SofaTabFragment videoFragment = new SofaTabFragment();
        {
            Bundle bundle = new Bundle();
            bundle.putString("target", "video");
            videoFragment.setArguments(bundle);
        }

        SofaTabFragment textFragment = new SofaTabFragment();
        {
            Bundle bundle = new Bundle();
            bundle.putString("target", "text");
            textFragment.setArguments(bundle);
        }
        fragments.add(imageFragment);
        fragments.add(videoFragment);
        fragments.add(textFragment);
        sofaSlidingLayout.setViewPager(sofaVp, new String[]{"图片", "视频", "文本"}, getActivity(), fragments);
        sofaSlidingLayout.setTextSelectColor(Color.RED);
        sofaSlidingLayout.setTextUnselectColor(Color.BLACK);
        sofaSlidingLayout.setIndicatorColor(Color.RED);
    }

    @Override
    public void onResume() {
        super.onResume();

    }



    @Override
    public void receiveData(Map<String, Object> data) {

    }
}
